package com.admin.socketmultiplayer.fragment

import android.content.Intent
import com.admin.socketmultiplayer.R
import com.admin.socketmultiplayer.adapter.ShowTypeAdapter
import com.admin.socketmultiplayer.bean.OptionType
import kotlinx.android.synthetic.main.fragment_homepager.view.*
import kotlinx.android.synthetic.main.layout_title.view.*

/**
 * Created by 吴昶 on 2018/5/14.
 */
class HomeFragment:BaseFragment(){

    var showAdapter:ShowTypeAdapter?=null
    var data=ArrayList<OptionType>()

    override fun bindLayout(): Int {
        return R.layout.fragment_homepager
    }

    override fun initData() {
        data.clear()
        fview!!.tv_title.text="首页"
        data.add(OptionType(R.mipmap.ioc_competition_answer,"答题大厅","进入大厅选择需要进入的房间或随机匹配对手","android.activity.ROOMLISTACTIVITY"))
        showAdapter=ShowTypeAdapter(activity!!,R.layout.layout_show_type_item,data)
        fview!!.lv_show_type.adapter=showAdapter
    }

    override fun initEvent() {
        fview!!.lv_show_type.setOnItemClickListener { adapterView, view, i, l ->
            var intent=Intent(showAdapter!!.getItem(i).action)
            startActivity(intent)
        }
    }

}